<template>
	<view class="content">
		<!-- <image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view> -->
		<view>
			接龙文本：<textarea v-model="solitaireText" maxlength='-1'></textarea>
		</view>
		<view>
			姓名清单(<span style="color: red;">姓名使用英文逗号隔开</span>)：<textarea v-model="namesText" maxlength='-1'></textarea>
		</view>
		<button @click="validTxt">比对</button>
		<view>
			<!-- {{result}} -->
			比对结果：<textarea v-model="result" maxlength='-1'></textarea>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				solitaireText:"",
				// namesText:"毕琳熙,陈家俊,陈志杰,崔净雅,翟炳坤,翟佳妍,翟泽佳,翟志涛,翟子轩,董涵宇,董志博,杜昀轩,付强,高千惠,高子涵,郭壮,韩新悦,郝龙越,何奕言,霍艺萱,贾函晔,李金洋,李梦菲,李欣,李洋,李泽淳,李志威,李子欢,刘城光,刘佳洁,刘林杰,刘雪依,刘忆雯,刘梓航,刘梓豪,刘紫滢,马箐芳,沈若萱,石丰硕,史浩东,史可敬,史林凯,孙玉然,田梦嫣,佟泽鑫,王佳伟,王凌薇,王梦琪,王湣冬,王润钊,王信博,王一菲,王雨涵,王紫涵,魏林溪,武煜涵,邢胜杰,邢依然,杨峻澎,杨熠彤,岳盈欣,张琳珊,张仕杰,张薇薇,张文彬,张宇轩,张雨,赵瑞泽,赵松涛,赵鑫,赵鑫苗,赵鑫仪,赵梓琛,赵紫悦",
				namesText:"",
				result:"请点击比对按钮"
			}
		},
		onLoad() {
			let that = this;
			uni.getStorage({
				key: 'storage_key',
				success: function (res) {
					console.log(res.data);
					that.namesText = res.data
				}
			});
		},
		methods: {
			validTxt(){
				var text1 = this.solitaireText;
				var namesStr = this.namesText;
				var names =namesStr.split(",");
				// debugger
				var res = "";
				for(var i=0;i<names.length;i++){
					if(text1.indexOf(names[i].trim())>=0){
						continue;
					}else{
						res += names[i] + ":";
					}
				}
				if(res===""){
					res = "都已接龙"
				}
				this.result = res
				uni.setStorage({
					key: 'storage_key',
					data: this.namesText,
					success: function () {
						console.log('success');
					}
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
